if select(2, UnitClass("player")) ~= "DEATHKNIGHT" then return end
local GT = LibStub:GetLibrary("LibGratuity-3.0")
local GetSpellInfo = GetSpellInfo
local IsEquippedItem = IsEquippedItem
local select = select

function DrDamage:PlayerData()

	--Special Calculation
	self.Calculation["Attack"] = function ( calculation, _, BuffTalentRanks )
		if BuffTalentRanks["Necrosis"] then
			calculation.dmgM = calculation.dmgM + ( 1 * BuffTalentRanks["Necrosis"] )
		end
	end
	
	self.Calculation["Two-Handed Weapon Specialization"] = function( calculation, value )
		if self:GetNormM() == 3.3 then
			if calculation.wDmgM then
				calculation.wDmgM = calculation.wDmgM * (1 + value)
			else
				calculation.dmgM = calculation.dmgM * (1 + value)
			end
		end
	end
	
	--General
	self.Calculation["DEATHKNIGHT"] = function( calculation, ActiveAuras, BuffTalentRanks, spell, baseSpell )
		--Spell AP Bonus
		local impurityBonus = 1
		if BuffTalentRanks["Impurity"] then
			impurityBonus = impurityBonus + BuffTalentRanks["Impurity"]
		end
		if not baseSpell.Melee then
			if baseSpell.SpellAPBonus then
				calculation.AP = self:GetAP()
				calculation.minDam = calculation.minDam + (calculation.AP * baseSpell.SpellAPBonus * impurityBonus)
				calculation.maxDam = calculation.maxDam + (calculation.AP * baseSpell.SpellAPBonus * impurityBonus)
			end
		end
		
		if BuffTalentRanks["Tundra Stalker"] then
			if ActiveAuras["Frost Fever"] then
				calculation.dmgM = calculation.dmgM + ( 1 * BuffTalentRanks["Tundra Stalker"] )
			end
		end
		if BuffTalentRanks["Rage of Rivendare"] then
			if ActiveAuras["Blood Plague"] then
				calculation.dmgM = calculation.dmgM + ( 1 * BuffTalentRanks["Rage of Rivendare"] )
			end
		end	
	end
	
	--Spell Specific
	self.Calculation["Blood Strike"] = function( calculation, _, BuffTalentRanks, spell )
		local bsStrike = 1
		local bsDisease = 1
		if BuffTalentRanks["Bloody Strikes"] then
			bsStrike = bsStrike + BuffTalentRanks["Bloody Strikes"]
			bsDisease = bsDisease + (2 * BuffTalentRanks["Bloody Strikes"])
		end
		calculation.minDam = (calculation.minDam * bsStrike) + (DrDamage.diseaseCount * spell.diseaseBonus * bsDisease)
		calculation.maxDam = (calculation.maxDam * bsStrike) + (DrDamage.diseaseCount * spell.diseaseBonus * bsDisease)
	end
	self.Calculation["Heart Strike"] = function( calculation, _, BuffTalentRanks, spell )
		local bsStrike = 1
		local bsDisease = 1
		if BuffTalentRanks["Bloody Strikes"] then
			bsStrike = bsStrike + BuffTalentRanks["Bloody Strikes"]
			bsDisease = bsDisease + (2 * BuffTalentRanks["Bloody Strikes"])
		end
		calculation.minDam = (calculation.minDam * bsStrike) + (DrDamage.diseaseCount * spell.diseaseBonus * bsDisease)
		calculation.maxDam = (calculation.maxDam * bsStrike) + (DrDamage.diseaseCount * spell.diseaseBonus * bsDisease)
	end
	self.Calculation["Scourge Strike"] = function( calculation, _, _, spell )
		calculation.minDam = calculation.minDam + (DrDamage.diseaseCount * spell.diseaseBonus)
		calculation.maxDam = calculation.maxDam + (DrDamage.diseaseCount * spell.diseaseBonus)
	end
	self.Calculation["Obliterate"] = function( calculation, _, _, spell )
		calculation.minDam = calculation.minDam + (DrDamage.diseaseCount * spell.diseaseBonus)
		calculation.maxDam = calculation.maxDam + (DrDamage.diseaseCount * spell.diseaseBonus)
	end
	
	self.Calculation["Blood Boil"] = function( calculation, _, _, spell, baseSpell )
		if DrDamage.diseaseCount ~= 0 then
			calculation.AP = self:GetAP()
			calculation.minDam = calculation.minDam + (calculation.AP * baseSpell.BoilSpellAPBonus)
			calculation.maxDam = calculation.maxDam + (calculation.AP * baseSpell.BoilSpellAPBonus)
		else
			calculation.minDam = 0
			calculation.maxDam = 0
		end
	end
	
	self.Calculation["Icy Touch"] = function( calculation, _, BuffTalentRanks, spell )
		if BuffTalentRanks["Glacier Rot"] then
			if DrDamage.diseaseCount > 0 then
				calculation.dmgM = calculation.dmgM * ( 1 + BuffTalentRanks["Glacier Rot"] )
			end
		end
	end
	
	self.Calculation["Howling Blast"] = function( calculation, ActiveAuras, BuffTalentRanks, spell )
		if ActiveAuras["Frost Fever"] then
			calculation.minDam = calculation.minDam * 2
			calculation.maxDam = calculation.maxDam * 2
		end
		if BuffTalentRanks["Glacier Rot"] then
			if DrDamage.diseaseCount > 0 then
				calculation.dmgM = calculation.dmgM * ( 1 + BuffTalentRanks["Glacier Rot"] )
			end
		end
	end
	
	self.Calculation["Frost Strike"] = self.Calculation["Icy Touch"]
	
	--Set Bonuses
	
	--Relic Bonuses
	
	--Auras
	--Death Trance! (from Sudden Doom)
	--Killing Machine
	--Death Chill
	self.PlayerAura[GetSpellInfo(50466)] = { Spell = GetSpellInfo(52375), Value = 100, ModType = "critPerc" }
	self.PlayerAura[GetSpellInfo(51124)] = { Spell = { GetSpellInfo(45477), GetSpellInfo(49184), GetSpellInfo(49143) }, Value = 100, ModType = "critPerc" }
	self.PlayerAura[GetSpellInfo(49796)] = { Spell = { GetSpellInfo(45477), GetSpellInfo(49184), GetSpellInfo(49143), GetSpellInfo(49020) }, Value = 100, ModType = "critPerc" }
	
	--Frost Fever
	--Blood Plague
	self.TargetAura[GetSpellInfo(55095)] = { ModType = "ActiveAura", ActiveAura = "Frost Fever" }
	self.TargetAura[GetSpellInfo(55078)] = { ModType = "ActiveAura", ActiveAura = "Blood Plague" }
	
	self.spellInfo = {
		--BLOOD
		[GetSpellInfo(45902)] = {
				["Name"] = "Blood Strike",
				[0] = { Melee = true, WeaponDamage = 0.5 },
				[1] = { 65, diseaseBonus = 32.5 },
				[2] = { 73.75, diseaseBonus = 36.875 },
				[3] = { 86.75, diseaseBonus = 43.375 },
				[4] = { 102.75, diseaseBonus = 51.35 },
				[5] = { 156.25, diseaseBonus = 78.125 },
				[6] = { 191, diseaseBonus = 92.5 },
		},
		[GetSpellInfo(50842)] = {
				["Name"] = "Pestilence",
				[0] = { School = "Shadow", Cooldown = 0, canCrit = true, SpellAPBonus = 0.04 },
				[1] = { 27, 33, spellLevel = 56 },
				[2] = { 32, 38, spellLevel = 62 },
				[3] = { 41, 45, spellLevel = 68 },
				[4] = { 54, 66, spellLevel = 74 },
				[5] = { 65, 79, spellLevel = 79 },
		},
		[GetSpellInfo(48721)] = {
				["Name"] = "Blood Boil",
				[0] = { School = "Shadow", BoilSpellAPBonus = 0.04, canCrit = true },
				[1] = { 59, 71, spellLevel = 58 },
				[2] = { 77, 93, spellLevel = 66 },
				[3] = { 99, 121, spellLevel = 72 },
				[4] = { 117, 143, spellLevel = 78 },
		},
		[GetSpellInfo(47476)] = {
				["Name"] = "Strangulate",
				[0] = { School = "Shadow", Cooldown = 120, canCrit = true, SpellAPBonus = 0.06 },
				[1] = { 80, 80, spellLevel = 59 },
				[2] = { 85, 85, spellLevel = 65 },
				[3] = { 110, 110, spellLevel = 69 },
				[4] = { 150, 150, spellLevel = 74 },
				[5] = { 180, 180, spellLevel = 79 },
		},
		[GetSpellInfo(55050)] = {
				["Name"] = "Heart Strike",
				[0] = { Melee = true, WeaponDamage = 0.6 },
				[1] = { 75, diseaseBonus = 37.5},
				[2] = { 85.2, diseaseBonus = 42.6},
				[3] = { 100.2, diseaseBonus = 50.1},
				[4] = { 118.5, diseaseBonus = 59.25},
				[5] = { 180.3, diseaseBonus = 90.15},
				[6] = { 220.8, diseaseBonus = 110.4},
		},
		--FROST
		[GetSpellInfo(45477)] = {
				["Name"] = "Icy Touch",
				[0] = { School = "Frost", canCrit = true, SpellAPBonus = 0.1 },
				[1] = { 127, 137, spellLevel = 55 },
				[2] = { 144, 156, spellLevel = 61 },
				[3] = { 161, 173, spellLevel = 67 },
				[4] = { 187, 203, spellLevel = 73 },
				[5] = { 227, 245, spellLevel = 78 },
		},
		[GetSpellInfo(49020)] = {
				["Name"] = "Obliterate",
				[0] = { Melee = true, WeaponDamage = 1 },
				[1] = { 124, diseaseBonus = 62 },
				[2] = { 152.5, diseaseBonus = 76.25 },
				[3] = { 238.5, diseaseBonus = 119 },
				[4] = { 292, diseaseBonus = 146 },
		},
		[GetSpellInfo(56815)] = {
				["Name"] = "Rune Strike",
				[0] = { Runic = 20, Melee = true, WeaponDamage = 2, APBonus = 0.2, NextMelee = true },
				["None"] = { 0 },
		},
		[GetSpellInfo(49184)] = {
				["Name"] = "Howling Blast",
				[0] = { School = "Frost", canCrit = true, SpellAPBonus = 0.1 },
				[1] = { 99, 101, spellLevel = 40 },
				[2] = { 117, 127, spellLevel = 60 },
				[3] = { 162, 176, spellLevel = 70 },
				[4] = { 221, 239, spellLevel = 75 },
				[5] = { 259, 281, spellLevel = 80 },
		},
		[GetSpellInfo(49143)] = {
				["Name"] = "Frost Strike",
				[0] = { Runic = 40, Melee = true, WeaponDamage = 0.6 },
				[1] = { 52.2 },
				[2] = { 61.8 },
				[3] = { 69 },
				[4] = { 85.2 },
				[5] = { 120.6 },
				[6] = { 150 },
		},
		--UNHOLY
		[GetSpellInfo(52375)] = {
				["Name"] = "Death Coil",
				[0] = { Runic = 40, School = "Shadow", canCrit = true, SpellAPBonus = 0.15 },
				[1] = { 184, 184, spellLevel = 55 },
				[2] = { 208, 208, spellLevel = 62 },
				[3] = { 275, 275, spellLevel = 68 },
				[4] = { 381, 381, spellLevel = 76 },
				[5] = { 443, 443, spellLevel = 80 },
			["Secondary"] = {
				["Name"] = "Death Coil",
				[0] = { Runic = 40, School = { "Shadow", "Healing" }, canCrit = true, SpellAPBonus = 0.15 },
				[1] = { 276, 276, spellLevel = 55 },
				[2] = { 312, 312, spellLevel = 62 },
				[3] = { 412.5, 412.5, spellLevel = 68 },
				[4] = { 571.5, 571.5, spellLevel = 76 },
				[5] = { 664.5, 664.5, spellLevel = 80 },
			},
		},
		[GetSpellInfo(45462)] = {
				["Name"] = "Plague Strike",
				[0] = { Melee = true, WeaponDamage = 0.3 },
				[1] = { 37.5 },
				[2] = { 45.3 },
				[3] = { 53.4 },
				[4] = { 64.8 },
				[5] = { 94.2 },
				[6] = { 113.4 },
		},
		[GetSpellInfo(49998)] = {
				["Name"] = "Death Strike",
				[0] = { Melee = true, WeaponDamage = 0.6 },
				[1] = { 67.2 },
				[2] = { 78 },
				[3] = { 99 },
				[4] = { 150 },
				[5] = { 178.2 },
		},
		[GetSpellInfo(43265)] = {
				["Name"] = "Death and Decay",
				[0] = { School = "Shadow", castTime = 10, sHits = 11, Cooldown = 30, SpellAPBonus = 0.0475 },
				[1] = { 26, 26, spellLevel = 60 },
				[2] = { 34, 34, spellLevel = 67 },
				[3] = { 49, 49, spellLevel = 73 },
				[4] = { 62, 62, spellLevel = 80 },
		},
		[GetSpellInfo(49158)] = {
				["Name"] = "Corpse Explosion",
				[0] = { School = "Shadow", canCrit = true, SpellAPBonus = 0.0475 },
				[1] = { 82, 82, spellLevel = 20 },
				[2] = { 95, 95, spellLevel = 60 },
				[3] = { 130, 130, spellLevel = 70 },
				[4] = { 190, 190, spellLevel = 75 },
				[5] = { 220, 220, spellLevel = 80 },
		},
		[GetSpellInfo(55090)] = {
				["Name"] = "Scourge Strike",
				[0] = { Melee = true, WeaponDamage = 0.6 },
				[1] = { 81, diseaseBonus = 40.5 },
				[2] = { 99.6, diseaseBonus = 49.8 },
				[3] = { 155.4, diseaseBonus = 77.7 },
				[4] = { 190.5, diseaseBonus = 92.25 },
		},
		[GetSpellInfo(49194)] = {
				["Name"] = "Unholy Blight",
				[0] = { School = "Shadow", eDot = true, eDuration = 20, sTicks = 1, SpellAPBonus = 0.25 },
				[1] = { 420, 420, spellLevel = 60 },
				[2] = { 600, 600, spellLevel = 70 },
				[3] = { 800, 800, spellLevel = 75 },
				[4] = { 960, 960, spellLevel = 80 },
		},
	}				
	
	self.talentInfo = {
		--BLOOD
		--Subversion
		--Two-Handed Weapon Specialization
		--Bloody Strikes
		--Might of Mograine
		[GetSpellInfo(48997)] = { 	[1] = { Effect = 3, Spells = { "Blood Strike", "Heart Strike", "Obliterate" }, ModType = "critPerc", }, },
		[GetSpellInfo(55107)] = { 	[1] = { Effect = 0.02, Melee = true, Spells = "Physical", ModType = "Two-Handed Weapon Specialization" }, },
		[GetSpellInfo(48977)] = {		[1] = { Effect = 0.1, Spells = { "Blood Strike", "Heart Strike" }, ModType = "Amount", Value = "Bloody Strikes", }, },
		[GetSpellInfo(49023)] = {		[1] = { Effect = 0.15, Spells = { "Blood Boil", "Blood Strike", "Death Strike", "Heart Strike", "Obliterate" }, ModType = "critM", }, },
		
		--FROST
		--Improved Icy Touch
		--Glacier Rot
		--Black Ice
		--Nerves of Cold Steel
		--Annihilation
		--Rime
		--Blood of the North
		--Guile of Gorefiend
		--Tundra Stalker
		[GetSpellInfo(49175)] = {		[1] = { Effect = 0.1, Spells = "Icy Touch" }, },
		[GetSpellInfo(49471)] = {		[1] = { Effect = 0.05, Spells = { "Icy Touch", "Howling Blast", "Frost Strike" }, ModType = "Amount", Value = "Glacier Rot" }, },
		[GetSpellInfo(49140)] = {		[1] = { Effect = 0.06, Spells = "Frost" }, },
		[GetSpellInfo(49226)] = {		[1] = { Effect = 0.05, Spells = "All", Melee = true, ModType = "offHdmgM", Multiply = true  }, NoManual = true },
		[GetSpellInfo(51468)] = {		[1] = { Effect = 1, Spells = "All", Melee = true, Specials = true, ModType = "critPerc" }, },
		[GetSpellInfo(49188)] = {		[1] = { Effect = 5, Spells = { "Icy Touch", "Obliterate" }, ModType = "critPerc" }, },
		[GetSpellInfo(54639)] = {		[1] = { Effect = 0.03, Spells = "Blood Strike" }, },
		[GetSpellInfo(50187)] = {		[1] = { Effect = 0.15, Spells = { "Blood Strike", "Frost Strike", "Howling Blast", "Obliterate" }, ModType = "critM", }, },
		[GetSpellInfo(49202)] = {		[1] = { Effect = 0.02, Spells = "All", ModType = "Amount", Value = "Tundra Stalker" }, },
		
		--UNHOLY
		--Vicious Strikes
		--Morbidity
		--Outbreak
		--Necrosis
		--Impurity
		--Rage of Rivendare
		[GetSpellInfo(51745)] = {		[1] = { Effect = 3, Spells = { "Plague Strike", "Death Strike", "Scourge Strike" }, ModType = "critPerc" },
																[2] = { Effect = 0.15, Spells = { "Plague Strike", "Death Strike", "Scourge Strike" }, ModType = "critM" }, },
		[GetSpellInfo(48963)] = {		[1] = { Effect = 0.05, Spells = "Death Coil" },
																[2] = { Effect = -5, Spells = "Death and Decay", ModType = "cooldown" }, },
		[GetSpellInfo(49013)] = {		[1] = { Effect = 0.1, Spells = { "Plague Strike", "Pestilence", "Blood Boil" }, }, },
		[GetSpellInfo(51459)] = {		[1] = { Effect = 0.02, Spells = "Attack", ModType = "Amount", Value = "Necrosis" }, },
		[GetSpellInfo(49220)] = {		[1] = { Effect = 0.05, Spells = "All", ModType = "Amount", Value = "Impurity" }, },
		[GetSpellInfo(50117)] = {		[1] = { Effect = 0.02, Spells = "All", ModType = "Amount", Value = "Rage of Rivendare" }, },
	}
end